// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 4/12/2007 09:14:37
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   RMenu.java

package utility;

import java.awt.*;
import java.util.Locale;

// Referenced classes of package de.escape.quincunx.i18n:
//            I18n, Localizable, RMenuItem

public class RMenu extends Menu
    implements Localizable
{

    public RMenu(String tag)
    {
        setTag(tag);
    }

    public RMenu(String tag, MenuShortcut sc)
    {
        setTag(tag);
        setShortcut(sc);
    }

    public void setTag(String tag)
    {
        resTag = tag;
        setLabel(I18n.getString(resTag, getLocale()));
    }

    public void setLocale(Locale l)
    {
        locale = l;
        setLabel(I18n.getString(resTag, l));
        for(int i = getItemCount() - 1; i >= 0; i--)
        {
            MenuItem m = getItem(i);
            if(m instanceof Localizable)
                ((Localizable)m).setLocale(l);
        }

    }

    public Locale getLocale()
    {
        if(locale == null && getParent() != null)
        {
            java.awt.MenuContainer m = getParent();
            if(m instanceof Localizable)
                return ((Localizable)m).getLocale();
        }
        return locale;
    }

    public MenuItem add(MenuItem m)
    {
        if(m instanceof Localizable)
        {
            Localizable l = (Localizable)m;
            if(l.getLocale() == null)
                l.setLocale(getLocale());
        }
        return super.add(m);
    }

    public void insert(MenuItem m, int index)
    {
        if(m instanceof Localizable)
        {
            Localizable l = (Localizable)m;
            if(l.getLocale() == null)
                l.setLocale(getLocale());
        }
        super.insert(m, index);
    }

    public void insert(String m, int index)
    {
        super.insert(new RMenuItem(m, getLocale()), index);
    }

    protected Locale locale;
    protected String resTag;
}